import cv2
from cvzone.HandTrackingModule import HandDetector

# 利用cv2模块识别手势

cap = cv2.VideoCapture(0)
# 设置高度
cap.set(3, 1280)
# 设置宽度 
cap.set(4, 720)
# 设置阈值
detector = HandDetector(detectionCon=0.7)

while True:
    success, img = cap.read()
    hands, img = detector.findHands(img)
    cv2.imshow("gestureHand", img)
    # cv2.waitKey(1)
    # 按 'q' 键退出
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
# 释放摄像头并关闭窗口
cap.release()
cv2.destroyAllWindows()